home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 797 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: cs.mu.OZ.AU!bounce-back
  2. From: "Nathan Myers, http://www.cantrip.org/" <ncm@cantrip.org>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Template instantiation
  5. Date: 21 Mar 96 02:48:58 GMT
  6. Organization: The Cantrip Cooperative
  7. Approved: fjh@cs.mu.oz.au
  8. Message-ID: <314FA6C4.6816C82B@cantrip.org>
  9. References: <4if8u9$6lf@jake.esu.edu>
  10. NNTP-Posting-Host: mundook.cs.mu.oz.au
  11. X-Original-Date: Tue, 19 Mar 1996 22:33:40 -0800
  12. X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.13 i386)
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMVDDuOEDnX0m9pzZAQHa9wF/QyVyoYiMNIO6P1k8K4K43agyAmCFglAd
  15.     xLCCFPfFzpu4WhC0AkK+Oo91jIXOFfiO
  16.     =EVTe
  17. Originator: fjh@mundook.cs.mu.OZ.AU
  18.  
  19. John E. Potter wrote:
  20. > I have only found one compiler which accepts the following.  The others
  21. > attempt to instantiate class N prior to completing class L.  As I read
  22. > DWP-14.3 [temp.inst], class N<int> should not be instantiated in the
  23. > following code.  It would be instantiated when some class L<int> function
  24. > used an N<int>.
  25. > template <class T> class N;
  26. > template <class T> class L { N<T>* ptr; };
  27. > template <class T> class N { L<T> next; };
  28. > int main () { L<int> l; }
  29. > Do I have one correct compiler that accepts it, several correct compilers
  30. > which reject it, or (I hope not) all correct compilers because it is not
  31. > specified?
  32.  
  33. You have one (at least semi-) correct compiler, and several broken ones.
  34.  
  35. > If the latter, is there any standard way to make this portable?  I can
  36. > change ptr to a void* and reinterpret_castrate everything, but that is
  37. > not very pleasing.
  38.  
  39. You could change the member to a void* and provide an (inline) access 
  40. function that does the cast, in only one place.  Better to use 
  41. non-broken compilers, of course.
  42.  
  43. Nathan Myers
  44. ncm@cantrip.org  http://www.cantrip.org/
  45. ---
  46. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  47. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  48. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  49. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  50. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  51.